package main

/**
 * @Author: DengLibin
 * @Date: Create in 2023-01-17 15:39:41
 * @Description: 给定二叉树的根节点 root ，返回所有左叶子之和。
 */

/**
 * @Author: DengLibin
 * @Date: Create in 2023-01-17 15:39:43
 * @Description:
 */
func sumOfLeftLeaves(root *TreeNode) int {
	if root == nil {
		return 0
	}
	var leftVal int
	//左节点是叶子节
	if root.Left != nil && root.Left.Left == nil && root.Left.Right == nil {
		leftVal = root.Left.Val
	}
	return leftVal + sumOfLeftLeaves(root.Left) + sumOfLeftLeaves(root.Right)

}
